package com.ruoyi.project.gy.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.gy.domain.TGupiao;
import com.ruoyi.project.gy.service.ITGupiaoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 股票Controller
 * 
 * @author shenghuilee
 * @date 2020-04-09
 */
@RestController
@RequestMapping("/gy/gupiao")
public class TGupiaoController extends BaseController
{
    @Autowired
    private ITGupiaoService tGupiaoService;

    /**
     * 查询股票列表
     */
    @PreAuthorize("@ss.hasPermi('gy:gupiao:list')")
    @GetMapping("/list")
    public TableDataInfo list(TGupiao tGupiao)
    {
        startPage();
        List<TGupiao> list = tGupiaoService.selectTGupiaoList(tGupiao);
        return getDataTable(list);
    }

    /**
     * 导出股票列表
     */
    @PreAuthorize("@ss.hasPermi('gy:gupiao:export')")
    @Log(title = "股票", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TGupiao tGupiao)
    {
        List<TGupiao> list = tGupiaoService.selectTGupiaoList(tGupiao);
        ExcelUtil<TGupiao> util = new ExcelUtil<TGupiao>(TGupiao.class);
        return util.exportExcel(list, "gupiao");
    }

    /**
     * 获取股票详细信息
     */
    @PreAuthorize("@ss.hasPermi('gy:gupiao:query')")
    @GetMapping(value = "/{gupiaoId}")
    public AjaxResult getInfo(@PathVariable("gupiaoId") Long gupiaoId)
    {
        return AjaxResult.success(tGupiaoService.selectTGupiaoById(gupiaoId));
    }

    /**
     * 新增股票
     */
    @PreAuthorize("@ss.hasPermi('gy:gupiao:add')")
    @Log(title = "股票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TGupiao tGupiao)
    {
        return toAjax(tGupiaoService.insertTGupiao(tGupiao));
    }

    /**
     * 修改股票
     */
    @PreAuthorize("@ss.hasPermi('gy:gupiao:edit')")
    @Log(title = "股票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TGupiao tGupiao)
    {
        return toAjax(tGupiaoService.updateTGupiao(tGupiao));
    }

    /**
     * 删除股票
     */
    @PreAuthorize("@ss.hasPermi('gy:gupiao:remove')")
    @Log(title = "股票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gupiaoIds}")
    public AjaxResult remove(@PathVariable Long[] gupiaoIds)
    {
        return toAjax(tGupiaoService.deleteTGupiaoByIds(gupiaoIds));
    }
}
